package cn.sz.dzy.provider.controller;


import cn.hutool.json.JSONUtil;
import cn.sz.dzy.common.pojo.FaceRequestObject;
import cn.sz.dzy.provider.service.IFaceService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: gta1400
 * @description:人脸接口
 * @author: DingZhenYun
 * @create: 2021-12-08 17:39
 **/
@Api(tags = "VIIDFaces")
@RestController
@RequestMapping("/VIID")
@Slf4j
public class FaceController {

    @Autowired
    private IFaceService faceService;

    @Value(value = "${server.username}")
    private String username;

    @Value(value = "${server.password}")
    private String password;

    @PostMapping("/Faces")
    public ResponseEntity<String> faces(HttpEntity<String> httpEntity){
        String body = httpEntity.getBody();
        HttpHeaders headers = httpEntity.getHeaders();
        log.info("face-body：{}", body);
        log.info("face-headers：{}", headers);
        FaceRequestObject faceRequestObject = JSONUtil.toBean(body, FaceRequestObject.class);
        log.info("unregisterRequestObject：{}", faceRequestObject.toString());
        ResponseEntity<String> responseEntity =faceService.faces(faceRequestObject);
        log.info("c--responseEntity：{}", responseEntity.toString());
        return responseEntity;
    }
}
